package org.adream.account.controller;

import java.util.List;

import org.adream.account.entity.GradeEntity;
import org.adream.account.service.GradeService;
import org.adream.account.util.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 等级 跳转页面
 * @author sl
 *
 */
@Controller
public class GradeController {
	
	private static final Logger logger = LoggerFactory.getLogger(GradeController.class);
	
	@Autowired
	private GradeService gradeService;
	
	//等级列表页
	@RequestMapping(value = "/gradePage")
	public ModelAndView gradeView() {
		ModelAndView mv = new ModelAndView("/grade/grade");
		return mv;
	}
	
	//等级增加页
	@RequestMapping(value = "/gradeAddPage")
	public ModelAndView gradeAddView() {
		ModelAndView mv = new ModelAndView("/grade/grade_add");
		return mv;
	}
	
	//等级修改页
	@RequestMapping(value = "/gradeEditPage")
	public ModelAndView gradeEditView(Integer gid) {
		ModelAndView mv = new ModelAndView("/grade/grade_edit");
		GradeEntity grade = gradeService.queryGradeByGid(gid);
		List<GradeEntity> pGrades = gradeService.queryGradesByPidAndDr(Constant.ZERO, Constant.ONE);
		mv.getModel().put("grade", grade);
		mv.getModel().put("pGrades", pGrades);
		return mv;
	}
}